package com.example.controller;

import com.example.common.Result;
import com.example.entity.Course;
import com.example.entity.CourseStudent;
import com.example.mapper.CourseSelMapper;
import com.example.service.CourseSelService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/courseSel")
public class CourseSelController {
        @Resource
        CourseSelService courseSelService;
        @PostMapping("/add")
        public Result add(@RequestBody CourseStudent coursestudent){

                courseSelService.add(coursestudent);
                return Result.success();
        }

        @GetMapping("/getAll")
        public Result selectAll(@RequestParam(defaultValue = "1")Integer pageNum,
                                @RequestParam(defaultValue = "10") Integer pageSize,
                                CourseStudent courseStudent){
                PageInfo<CourseStudent> courseStudents = courseSelService.selectAll(pageNum,pageSize,courseStudent);
                return Result.success(courseStudents);
        }
        @DeleteMapping("/delete/{id}")
        public Result deleteByid(@PathVariable Integer id){
                courseSelService.deleteByid(id);
                return Result.success();
        }
}
